package com.example.test.OperateLinux;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * @author 晓果冻
 * @version 1.0
 * @date 2021/11/21 22:35
 */
public class ExecShell {
    public static void main(String[] args) {
            InputStream in = null;
            try {
                Process pro = Runtime.getRuntime().exec(new String[]{"sshpass -p wscgd.05.26?! ssh -p 22 root@49.232.174.28","docker ps -a"});
                pro.waitFor();
                in = pro.getInputStream();
                BufferedReader read = new BufferedReader(new InputStreamReader(in));
                String result = read.readLine();
                System.out.println("INFO:"+result);
            } catch (Exception e) {
                e.printStackTrace();
            }
    }
}
